package PL.practica4vs2;


import java.io.IOException;

import org.antlr.runtime.ANTLRFileStream;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.Token;
import PL.practica4vs2.AnalizadorEjemplo;

public class Procesador {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws RecognitionException 
	 */
	public static void main(String[] args) throws IOException{
		if (args[0].endsWith(".txt")){
			CharStream cs = new ANTLRFileStream(args[0]);
			AnalizadorEjemplo lex = new AnalizadorEjemplo(cs);
			Token token =   lex.nextToken();
			System.out.println(token);
			while(token.getType() != Token.EOF) {
				System.out.println(token);
				token =  lex.nextToken();
				
			}

		}
		if (args[0].endsWith(".c")){
			CharStream cs = new ANTLRFileStream(args[0]);
			AnalizadorC lex = new AnalizadorC(cs);
			//CommonTokenStream tokens = new CommonTokenStream(lex);
			Token token =   lex.nextToken();
			System.out.println(token);
			while(token.getType() != Token.EOF) {
				token =  lex.nextToken();
				System.out.println(token);
			}
		}
		if (args[0].endsWith(".xml")){
			CharStream cs = new ANTLRFileStream(args[0]);
			AnalizadorXml lex = new AnalizadorXml(cs);
			Token token =   lex.nextToken();
			System.out.println(token);
			while(token.getType() != Token.EOF) {
				token =  lex.nextToken();
				System.out.println(token);
			}
		}

	}

}
